Skip to content

Conversation

@davydog187
Copy link
Contributor

Summary

Implements _G global table - a table containing references to the global environment.

Implementation

  • Creates a table populated with all global functions
  • Sets _G._G to reference itself
  • Available at stdlib installation time

Tests

✅ 3 tests passing:

  • _G exists and is a table
  • _G contains standard library functions (_G.print == print)
  • _G._G == _G (self-reference)

⏭️ 2 tests skipped (future enhancement):

  • Live sync between _G and globals (requires metamethods)
  • Setting/reading globals via _G dynamically

Limitations

Current implementation is a snapshot of globals at initialization time. For full Lua 5.3 compatibility, _G would need to be a live reference using __index/__newindex metamethods. This is sufficient for most Lua 5.3 test suite needs.

Test Results

mix test
1089 tests, 0 failures, 32 skipped

Dave Lucia added 2 commits February 10, 2026 20:00
Implements _G as a table containing references to global functions.

Features:
- _G exists and is a table
- _G contains standard library functions
- _G._G references itself

Limitations (marked as skipped tests):
- Not a live reference (changes don't sync with globals)
- Full live reference would require metamethods or VM changes

Tests: 3 passing, 2 skipped
All existing tests pass (1089 tests, 0 failures)
@davydog187 davydog187 merged commit 2fa05d1 into main Feb 11, 2026
2 checks passed
@davydog187 davydog187 deleted the add-global-G-table branch February 11, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant